package cn.samler.diandi.api.model.io;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

@Data
public class Response {
    public static class RetCode {
        public static final int RET_SUCCESS = 0;
        public static final int RET_FAILURE = -1;

        public static final int RET_ACCESS_TOKEN_REFRESHED = 1000;
        public static final int RET_ACCESS_TOKEN_INVALID = 1001;
    }

    private int ret;
    private String msg;
    private Object data;

    public static Response getInstance(int ret, String msg, Object data) {
        Response resp = new Response();
        resp.setRet(ret);
        resp.setMsg(msg);
        resp.setData(data);

        return resp;
    }

    @JsonIgnore
    public boolean isSuccess() {
        return ret == RetCode.RET_SUCCESS;
    }

}
